package com.icss.lesson5;

import java.util.Set;
import java.util.TreeSet;

public class TestMain2 {
    public static void main(String[] args) {

        Set<Integer> set = new TreeSet<>();

        set.add(2);
        set.add(5);
        set.add(1);
        set.add(4);
        System.out.println(set.add(1)); // 去重
        System.out.println(set.size()); // 4
        System.out.println("----");
        set.forEach(System.out::println); // 升序拍好顺序(x < y) ? -1 : ((x == y) ? 0 : 1
        // 0 代表相等，  正数1代表大于，  负数-1代表小于


        Set<Student> set2 = new TreeSet<>();

        set2.add(new Student(4, "YYY"));
        set2.add(new Student(5, "jerry"));
        set2.add(new Student(2, "jerry"));
        set2.add(new Student(1, "tom"));
        set2.add(new Student(3, "XXXX"));
        System.out.println(set2.add(new Student(4, "ZZZZ")));
        System.out.println(set2.size()); // 4
        System.out.println("----");
        set2.forEach(System.out::println);



    }
}
